<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>组合式API的了解-选项api</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/3.2.40/vue.global.js"></script>
  </head>
  <body>
    <div id="app">
      <p>count:{{ count }}</p>
      <p>double:{{ double }}</p>
      <button @click="increase">increase</button>
    </div>
    <script>
      const { createApp } = Vue
      createApp({
        // 响应式数据声明
        data() {
          return {
            count: 0,
          }
        },
        // 方法调用
        methods: {
          increase() {
            this.count++
          },
        },
        // 计算属性
        computed: {
          double() {
            return this.count * 2
          },
        },
        // 监控对象
        watch: {
          count(newVal, oldVal) {
            console.log(newVal, oldVal)
          },
        },
      }).mount('#app')
    </script>
  </body>
</html>
